﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using Bitis_KeToanThue_Pro_DungChung.Common;

namespace Bitis_KeToanThue_Pro_QuanTri.AccessDatabase
{
   public class CapQuyenMenuChoNguoiDung
    {
        AccessData ac = new AccessData(1);
        public DataTable loadluoicapquyen(int manhom)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@MaNhom", SqlDbType.Int);
            arrPara[0].Value = manhom;
            return ac.ftblDocDuLieuSP("capquyenloaddulieucapquyen", arrPara);
        }
        public int them(int manhomuser,int manhommenu,int machuongtrinh,int IDViTri,int ID)
        {
            SqlParameter[] arrPara = new SqlParameter[5];
            arrPara[0] = new SqlParameter("@MaNhomUser", SqlDbType.Int);
            arrPara[0].Value = manhomuser;
            arrPara[1] = new SqlParameter("@MaNhomMenu", SqlDbType.Int);
            arrPara[1].Value = manhommenu;
            arrPara[2] = new SqlParameter("@MaChuongTrinh", SqlDbType.Int);
            arrPara[2].Value = machuongtrinh;
            arrPara[3] = new SqlParameter("@IDViTri", SqlDbType.Int);
            arrPara[3].Value = IDViTri;
            arrPara[4] = new SqlParameter("@ID", SqlDbType.Int);
            arrPara[4].Value = ID;
            DataTable dt = ac.ftblDocDuLieuSP("capquyenmenu_them", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int xoadong(int id)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@ID", SqlDbType.Int);
            arrPara[0].Value = id;

            DataTable dt = ac.ftblDocDuLieuSP("capquyenxoaid", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int xoa(int manhom)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@MaNhom", SqlDbType.Int);
            arrPara[0].Value = manhom;

            DataTable dt = ac.ftblDocDuLieuSP("capmenu_resetgroup", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public DataTable loadluoivitri(int manhom)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@MaNhom", SqlDbType.Int);
            arrPara[0].Value = manhom;
            return ac.ftblDocDuLieuSP("capmenu_loadgridvitri", arrPara);
        }
        public DataTable loadluoichuongtrinh(int manhom)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@MaNhom", SqlDbType.Int);
            arrPara[0].Value = manhom;
            return ac.ftblDocDuLieuSP("capmenu_loadgridchuongtrinh", arrPara);
        }
        public DataTable loadluoinhommenu(int manhom)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@MaNhom", SqlDbType.Int);
            arrPara[0].Value = manhom;
            return ac.ftblDocDuLieuSP("capmenu_loadgridnhommenu",arrPara);
        }
        public DataTable loadgirdnhomnguoidung()
        {

            return ac.ftblDocDuLieuSP("capmenu_loadgridnhomnguoidung", null);
        }
    }
}
